<?php

namespace app\util;

class Util
{
    /*
    * 返回json
    */
    public static function ajaxReturn($status, $info, $data)
    {
        $array = [
            'status' => $status,
            'info' => $info,
            'data' => $data,
        ];

        return $array;
    }

    /*
    * 生成盐
    */
    public static function generateSalt()
    {
        $string = 'abcdefghijqlmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';

        $length = strlen($string);
        
        $salt = '';
        for ($i = 0; $i < 4; $i++) {
            $rand = mt_rand(0, $length - 1);
            $char = substr($string, $rand, 1);
            $salt = $salt . $char;
        }

        return $salt;
    }
    

}
